package com.hex.ds.hdtp.core.inf.data.table.repository.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hex.ds.hdtp.core.inf.common.page.Page;
import com.hex.ds.hdtp.core.inf.common.page.converter.IPageAndMyBatisPlusPageConverter;
import com.hex.ds.hdtp.core.inf.data.table.mapper.ITableTransferRunLogMapper;
import com.hex.ds.hdtp.core.inf.data.table.po.TableTransferRunLogPo;
import com.hex.ds.hdtp.core.inf.data.table.repository.ITableTransferRunLogRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Package com.hex.ds.hdtp.core.inf.data.table.repository.impl
 * @ClassName TableTransferTaskRepository
 * @Description 表迁移任务-数据接口实现类
 * @Author Wang zhihao
 * @Date 2023/8/8 18:42
 * @Version v1.0
 **/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TableTransferRunLogRepository implements ITableTransferRunLogRepository {

    private final ITableTransferRunLogMapper tableTransferRunLogMapper;

    private final IPageAndMyBatisPlusPageConverter pageConverter;

    /**
     * @Method queryListByPage
     * @Param
     * @param tableTransferRunLogPo
     * @param toPage
     * @Return com.hex.ds.hdtp.core.inf.common.page.Page<com.hex.ds.hdtp.core.inf.data.table.po.TableTransferRunLogPo>
     * @Description 分页查询
     * @Author Wang zhihao
     * @Date 2023/8/9 14:26
     * @Version V1.0
     */
    @Override
    public Page<TableTransferRunLogPo> queryListByPage(TableTransferRunLogPo tableTransferRunLogPo, Page toPage) {
        final IPage tmpPageReslt = tableTransferRunLogMapper.queryListByPage(
                pageConverter.toMyBatisPlusPage(toPage)
                , tableTransferRunLogPo
        );
        final List list = tmpPageReslt.getRecords();
        final Page pageResult = pageConverter.toPage(tmpPageReslt);
        return pageResult.setData(list);
    }

    /**
     * @Method queryById
     * @Param
     * @param pkId
     * @Return com.hex.ds.hdtp.core.inf.data.table.po.TableTransferRunLogPo
     * @Description 根据主键查询
     * @Author Wang zhihao
     * @Date 2023/8/9 14:26
     * @Version V1.0
     */
    @Override
    public TableTransferRunLogPo queryById(String pkId) {
        return tableTransferRunLogMapper.selectById(pkId);
    }

    /**
     * @Method add
     * @Param
     * @param tableTransferRunLogPo
     * @Return java.lang.Integer
     * @Description 新增
     * @Author Wang zhihao
     * @Date 2023/8/9 14:27
     * @Version V1.0
     */
    @Override
    public Integer add(TableTransferRunLogPo tableTransferRunLogPo) {
        return tableTransferRunLogMapper.insert(tableTransferRunLogPo);
    }

    /**
     * @Method modifyById
     * @Param
     * @param tableTransferRunLogPo
     * @Return java.lang.Integer
     * @Description 通过主键修改
     * @Author Wang zhihao
     * @Date 2023/8/9 14:27
     * @Version V1.0
     */
    @Override
    public Integer modifyById(TableTransferRunLogPo tableTransferRunLogPo) {
        return tableTransferRunLogMapper.updateById(tableTransferRunLogPo);
    }

    /**
     * @Method removeById
     * @Param
     * @param pkId
     * @Return java.lang.Integer
     * @Description 通过主键删除
     * @Author Wang zhihao
     * @Date 2023/8/9 14:27
     * @Version V1.0
     */
    @Override
    public Integer removeById(String pkId) {
        return tableTransferRunLogMapper.deleteById(pkId);
    }

}
